******************************************
*
*	Article: The Human Costs of the War on Drugs: Attitudes towards Militarization of Security in Mexico
*	Authors: Juan Masullo J., Davide Morisi
*	Journal: Comparative Political Studies
*	Date: 23 March 2023
*
*	This file replicates the following
*	RECODING DATASET FOR STUDY 1
*
*	All analyses performed with Stata/SE 14.2 for Windows
******************************************

*Set working directory
*[my working directory]

*open file
use "Replication_CPS\Data\study1.dta", clear

**************
*DV
*¿qué tan favorable o desfavorable es su opinión sobre el uso de las fuerzas militares en el combate contra el crimen organizado?
fre armyopinion
gen dv_att = armyopinion/10
label var dv_att "How favorable is your opinion about the use of military force in combat against"
label de dv_att 0"Highly unfavorable" 1"Highly favorable"
label values dv_att dv_att
fre dv_att
*standardized
egen st_dv_att = std(dv_att)

*Attention check
fre bolillo
recode bolillo (3=1 "correct") (1 2 4 5=0 "wrong"), gen(manip_check)
fre manip_check
*logit manip_check i.group // no differences among groups


**************
*victime of crime
fre victim
recode victim (1=0 "not victim") (2/3=1 "victim"), gen(vict2)

*victim of cartel related crime
gen victim_cartelA = 0
replace victim_cartelA = 1 if cartelmurder==1 & novictim==0
replace victim_cartelA = 1 if extortion==1 & novictim==0
replace victim_cartelA = 1 if kidnap==1 & novictim==0
replace victim_cartelA = 1 if robbery==1 & novictim==0
replace victim_cartelA = 1 if disappear==1 & novictim==0
label var victim_cartelA "Victim of murder/extortion/kidnap/armed rob/disappear"
label de victim_cartel 0"no" 1"Yes"
label values victim_cartelA victim_cartel
fre victim_cartelA

*combining measures
fre vict2
ta vict2 victim_cartelA
gen victim_cartel = 0
replace victim_cartel = 1 if vict2==1 & victim_cartelA==1
label var victim_cartel "Victim crime + murder/extortion/kidnap/armed rob/disappear"
label val victim_cartel vict2
fre victim_cartel


**************
*trust in army
fre trust_army
rename trust_army trust_army_study1
gen trust_army01 = (trust_army_study1-1)/10
label var trust_army01 "How much trust in the Army?"
label de trust 0"none" 1"a lot", modify
label values trust_army01 trust
ta trust_army01
sum trust_army01, d


**************
*socio demographics

*Gender
fre gender
fre female // 0=male(other), 1=female

*Age
ta age
sum age, d
*graph box age
recode age (18=1 "18") (19/20=2 "19/20") (21/24=3 "21/24") (25/53=4 "25+"), gen(agecat)
fre agecat

*Edu
fre years_school 
sum years_school, d 
recode years_school (7/12=1 "below uni") (13/22=2 "uni or above"), gen(edu_uni)
ta edu_uni


***
*Add variables for merging datasets

*group
clonevar group_study1 = group

*study
gen study = 1 // 1 = study 1

*id
gen id = _n


***
save "Replication_CPS\Data\study1_recoded.dta", replace





